package com.zhku.onlineshop.Dao;

import com.zhku.onlineshop.Pojo.Address;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Mapper
public interface AddressDao {

    @Insert("INSERT INTO address (address, name, phone,user_id) VALUES (#{address}, #{name}, #{phone},#{user_id})")
     boolean AddAddress(Address address) ;

    @Delete("DELETE FROM address WHERE id = #{id}")
    boolean DelAddressById(Integer id);

    @Update("UPDATE address SET address = #{address} ,name= #{name}, phone = #{phone} WHERE id = #{id}")
    boolean UpdAddressById(Address address);

    @Select("SELECT * FROM  address WHERE  user_id = #{user_id}")
    List<Address> SelAddressById(@Param("user_id") Integer userId);

    @Select("SELECT * FROM  address WHERE  id = #{id}")
    List<Address> SelAddressByAddressId(@Param("id") Integer id);
}
